﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using EnvDTE;
using Microsoft.VisualStudio.TemplateWizard;

namespace Creventive.Wpf.ShellFactory.TemplateWizard
{
    public class BasicSolutionTemplateWizard: IWizard
    {
        private static string SafeSolutionName;

        public void RunStarted(object automationObject, Dictionary<string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams)
        {
            //_DTE dte = (_DTE)automationObject;
            //if (runKind == WizardRunKind.AsMultiProject)
            //{
            //    MessageBox.Show(string.Join(Environment.NewLine, dte.Solution.Projects.Cast<Project>().Select(p => p.Name).ToArray()));
            //}
            if (runKind == WizardRunKind.AsMultiProject)
                SafeSolutionName = replacementsDictionary["$safeprojectname$"];
            replacementsDictionary["$safesolutionname$"] = SafeSolutionName;
        }

        public bool ShouldAddProjectItem(string filePath)
        {
            return true;
        }

        public void RunFinished()
        { }

        public void BeforeOpeningFile(ProjectItem projectItem)
        { }

        public void ProjectItemFinishedGenerating(ProjectItem projectItem)
        { }

        public void ProjectFinishedGenerating(Project project)
        { }
    }
}
